import Cookies from "js-cookie";
import { useUserStoreHook } from "/@/store/modules/user";

const TokenKey = "vue-book-admin";

type paramsMapType = {
  name: string;
  expires: number;
  accessToken: string;
};
export function getToken() {
  return Cookies.get(TokenKey);
}

export const setToken = (token: string, cookieExpires: any) => {
  const data = {
    accessToken: token, username: "admin"
  }
  Cookies.set(TokenKey, JSON.stringify(data), { expires: cookieExpires || 1 })
}
// 删除token
export function removeToken() {
  Cookies.remove(TokenKey);
  sessionStorage.removeItem(TokenKey);
}
